#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
    int data;
    struct node* next;
}LNode;

void SListPushBack(LNode** phead,int x)
{
    LNode* newnode=(LNode*)malloc(sizeof(LNode));
    newnode->data=x;
    newnode->next=NULL;
    if(*phead==NULL)
    {
        *phead=newnode;
    }
    else
    {
        LNode* cur=*phead;
        while(cur->next!=NULL)
        {
            cur=cur->next;
        }
        cur->next=newnode;
    }
}
void Link(LNode *A,LNode *B)
{
    LNode* cur=B;
    while(cur->next!=NULL)
    {
        cur=cur->next;
    }
    cur->next=A;
}
int main()
{
    LNode* Aplist=NULL;
    int n;
    while((scanf("%d",&n)!=EOF)&&(n>0))
    {
        SListPushBack(&Aplist,n);
    }
    LNode *Bplist=NULL;
    while((scanf("%d",&n)!=EOF)&&(n>0))
    {
        SListPushBack(&Bplist,n);
    }
   Link(Aplist,Bplist);
    LNode* tail=Bplist;
    while(tail!=NULL)
    {
        printf("%d ",tail->data);
        tail=tail->next;
    }
    return 0;
}
